{% extends base_template %}
{% load i18n %}
{% load xadmin_tags %}
{% load crispy_forms_tags %}

{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}

{% block nav_title %}{% if model_icon %}<i class="{{model_icon}}"><sub class="fa fa-{% if add%}plus{%else%}pencil{%endif%}"></sub></i> {% endif %}
{{ title }}{% endblock %}

{% block content %}
<script type="text/javascript">
    $(function(){
        var onfail = "{{ form.onfail.value }}"
        var onfailchecked = document.getElementsByName("onfail");
        if(onfail.indexOf("unconditional")>-1)
            onfailchecked[0].checked = true
        if(onfail.indexOf("USER_NOT_REGISTERED")>-1)
            onfailchecked[1].checked = true
        if(onfail.indexOf("USER_BUSY")>-1)
            onfailchecked[2].checked = true
        if(toll_allow.indexOf("TIMEOUT")>-1)
            onfailchecked[3].checked = true
        if(toll_allow.indexOf("NO_ANSWER")>-1)
            onfailchecked[4].checked = true
    });
    </script>
<form class="exform" {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form">
    {% csrf_token %}
    {% if errors %}
    <div class="alert alert-danger alert-dismissable">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        {% blocktrans count counter=errors|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
    </div>
    {{ form.non_field_errors }}

    {% endif %}
    <div class="form-container row clearfix">
        <div id="column-0" class="formColumn column form-column full col col-sm-12 form-horizontal" span="12" horizontal>
            <div class="panel panel-default fieldset unsort no_title" id="box-0">
                <div class="panel-heading"><i class='icon fa fa-chevron-up chevron'></i><h3 class="panel-title"></h3></div> <div class="panel-body ">
                    <div id="div_id_groupname" class="form-group {% if form.groupname.errors %} has-error{% endif %}">
                        <label for="id_groupname" class="control-label  requiredField">
                            别名(英文)<span class="asteriskField">*</span>
                        </label>
                        <div class="controls ">
                            <input class="text-field admintextinputwidget form-control" id="id_groupname" maxlength="32" name="groupname"
                                   type="text" {% if form.groupname.value %}value="{{ form.groupname.value }}" {% endif %} />
                            {% if form.groupname.errors %}<span id="error_1_id_groupname" class="help-block"><strong>{{ form.groupname.errors }}</strong></span>{% endif %}
                        </div>
                    </div>
                    <div id="div_id_destination_number" class="form-group {% if form.destination_number.errors %} has-error{% endif %}">
                        <label for="id_destination_number" class="control-label  requiredField">
                            分组表达式<span class="asteriskField">*</span>
                        </label> <div class="controls ">
                            <input class="text-field admintextinputwidget form-control" id="id_destination_number" maxlength="100" name="destination_number" type="text" {% if form.destination_number.value %}value="{{ form.destination_number.value }}" {% endif %} />
                            {% if form.groupname.errors %}<span id="error_1_id_name" class="help-block"><strong>{{ form.destination_number.errors }}</strong></span>{% endif %}
                        </div>
                    </div> <div id="div_id_user_number" class="form-group {% if form.user_number.errors %} has-error{% endif %}">
                        <label for="id_user_number" class="control-label  requiredField">
                            分机号码<span class="asteriskField">*</span>
                        </label> <div class="controls ">
                            <textarea class="textarea-field admintextareawidget form-control" cols="40" id="id_user_number" name="user_number" rows="3">{% if form.user_number.value %}{{ form.user_number.value }}{% endif %}</textarea>
                            {% if form.groupname.errors %}<span id="error_1_id_name" class="help-block"><strong>{{ form.user_number.errors }}</strong></span>{% endif %}
                            同振用,间隔(如:1000,1001,1002)顺振用|间隔(如:1000|1001|1002)
                        </div>
                    </div>
                    <div id="div_id_TIMEOUT" class="form-group {% if form.TIMEOUT.errors %} has-error{% endif %}">
                        <label for="id_TIMEOUT"
                               class="control-label  requiredField">
                            超时(秒)<span class="asteriskField">*</span>
                        </label>
                        <div class="controls ">
                            <input class="int-field adminintegerfieldwidget form-control"
                                   id="id_TIMEOUT" name="TIMEOUT" type="text" {% if form.TIMEOUT.value %}value="{{ form.TIMEOUT.value }}" {% endif %} />
                            {% if form.TIMEOUT.errors %}<span id="error_1_id_TIMEOUT" class="help-block"><strong>{{ form.TIMEOUT.errors }}</strong></span>{% endif %}
                        </div>
                    </div>
                    <div id="div_id_onfail" class="form-group">
                        <label for="id_onfail"
                               class="control-label">
                            转移条件
                        </label>
                        <div class="controls ">
                            <input name="onfail" type="checkbox" value="unconditional" />无条件
                            <input name="onfail" type="checkbox" value="USER_NOT_REGISTERED,NORMAL_TEMPORARY_FAILURE,NO_ROUTE_DESTINATION" />离线转移
                            <input name="onfail" type="checkbox" value="USER_BUSY" />遇忙转
                            <input name="onfail" type="checkbox" value="TIMEOUT" />超时转
                            <input name="onfail" type="checkbox" value="NO_ANSWER" />无应答转
                        </div>
                    </div>
                    <div id="div_id_failnum" class="form-group">
                        <label for="id_failnum" class="control-label ">
                            转移号码
                        </label>
                        <div class="controls ">
                            <input class="text-field admintextinputwidget form-control"
                                   id="id_failnum" maxlength="100"
                                   name="failnum" type="text" {% if form.failnum.value %}value="{{ form.failnum.value }}"{% endif %}/>
                        </div>
                    </div>
                    <div id="div_id_sort" class="form-group {% if form.sort.errors %}has-error{% endif %}">
                        <label for="id_sort" class="control-label  requiredField">
                            排序<span class="asteriskField">*</span>
                        </label> <div class="controls ">
                            <input class="int-field adminintegerfieldwidget form-control" id="id_sort" name="sort" type="text" {% if form.sort.value %}value="{{ form.sort.value }}" {% endif %} />
                            {% if form.groupname.errors %}<span id="error_1_id_name" class="help-block"><strong>{{ form.sort.errors }}</strong></span>{% endif %}
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    {% block submit_buttons_bottom %}{% include "submit_line.html" %}{% endblock %}
</form>
{% endblock %}